﻿using System;
using System.Diagnostics;

namespace Fibonacci
{
    class Program
    {
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();

            for (uint i = 0; i < Fibonacci.Capacity; i++)
            {
                //Console.WriteLine(i + ": " + FibL(i));
                Console.WriteLine(i + ": " + Fibonacci.Calculate(i));
            }

            sw.Stop();

            Console.WriteLine("Elapsed Time: {0}", sw.ElapsedMilliseconds);
            //Console.WriteLine(FibL(99));
            //Console.WriteLine(Fib(99));

            Console.WriteLine("---------------");

            Console.ReadKey();
        }

        static ulong[] lookup = new ulong[100];
        static ulong FibL(uint n)
        {
            if (n == 0) return 0;
            if (n == 1) return 1;

            if (lookup[n] == 0)
            {
                lookup[n] = FibL(n - 1) + FibL(n - 2);
            }

            return lookup[n];
        }

        static ulong Fib(uint n)
        {
            if (n == 0) return 0;
            if (n == 1) return 1;

            return Fib(n - 1) + Fib(n - 2);
        }
    }
}
